<?php

/**
* @Author:  	Daniel Dinh
* @Email:   	webdevelopmentvn@gmail.com
* @Link: 		http://www.joomsoft.net
* @Version: 	1.0
* @copyright:	Joomsoft.net
* @license:		GNU GPL v3
*/

// no direct access
defined('_JEXEC') or die;
// load tooltip behavior
JHtml::_('behavior.tooltip');
JHtml::_('behavior.multiselect');

$user		= JFactory::getUser();
$userId		= $user->get('id');
$listOrder	= $this->escape($this->state->get('list.ordering'));
$listDirn	= $this->escape($this->state->get('list.direction'));
$canOrder	= $user->authorise('core.edit.state', 'com_danipro.products');
$saveOrder	= $listOrder=='a.ordering';
$params		= (isset($this->state->params)) ? $this->state->params : new JObject();

?>

<form action="<?php echo JRoute::_('index.php?option=com_danipro&view=products'); ?>" method="post" name="adminForm">
<div style="margin-bottom:20px;">
 <table width="100%">
 	<tr>
			<td width="50%"></td>
			<td align="right">
				<?php echo DaniProHelper::getCategoryList();?>
				<?php echo DaniProHelper::getSupplierList();?>
				<?php echo DaniProHelper::getCountryList();?>
			</td>
	</tr>
 </table>
</div>
  <table class="adminlist">
    <thead>
      <tr>
        <th width="5">#</th>
        <th width="20"> <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" /></th>
        <th><?php echo JHtml::_("grid.sort", "COM_DANIPRO_PRODUCTS_HEADING_FIELD_TITLE", "a.title", $listDirn, $listOrder); ?></th>
        <th width="5%"><?php echo JText::_("COM_DANIPRO_PRODUCTS_HEADING_FIELD_MEDIA");?></th>
        <th><?php echo JText::_("COM_DANIPRO_PRODUCTS_HEADING_FIELD_CATEGORY");?></th>
        <th><?php echo JText::_("COM_DANIPRO_PRODUCTS_HEADING_FIELD_SUPPLIER");?></th>
        <th width="5%"><?php echo JText::_("COM_DANIPRO_PRODUCTS_HEADING_FIELD_UNIT");?></th>
        <th width="10%"><?php echo JText::_("COM_DANIPRO_PRODUCTS_HEADING_FIELD_PRICE");?></th>
        <th width="10%"><?php echo JText::_("COM_DANIPRO_PRODUCTS_HEADING_FIELD_MADEIN");?></th>
        <th width="5%"><?php echo JHtml::_("grid.sort", "JSTATUS", "a.published", $listDirn, $listOrder); ?></th>
		<th width="5%">
			<?php echo JHtml::_('grid.sort', 'COM_DANIPRO_PRODUCTS_FIELD_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
		</th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <td colspan="12"><?php echo $this->pagination->getListFooter(); ?></td>
      </tr>
    </tfoot>
    <tbody>
      <?php 
	  foreach($this->items as $i => $item): 
		$ordering	= ($listOrder == 'ordering');
		$canCreate	= $user->authorise('core.create',		'com_danipro.products.'.$item->id);
		$canEdit	= $user->authorise('core.edit',			'com_danipro.products.'.$item->id);
		$canChange	= $user->authorise('core.edit.state',	'com_danipro.products.'.$item->id);
		$editlink = JRoute::_('index.php?option=com_danipro&task=product.edit&id=' . $item->id);
	  
	  ?>
      <tr class="row<?php echo $i % 2; ?>">
        <td><?php echo $this->pagination->getRowOffset( $i ); ?> </td>
        <td><?php echo JHtml::_('grid.id', $i, $item->id); ?> </td>
	    <td><a href="<?php echo $editlink;?>"><?php echo $item->title; ?></a></td>
	    <td align="center"><a href="index.php?option=com_danipro&view=media&layout=edit&pid=<?php echo $item->id;?>">Upload</a></td>
	    <td align="center"><?php echo $item->categorytitle; ?></td>
	    <td align="center"><?php echo $item->suppliertitle; ?></td>
	    <td align="center"><?php echo $item->weight.'kg/'.DaniProHelper::getPackageName($item->unit); ?></td>
	    <td align="center"><strong style="color:#FF0000;"><?php echo $item->price.'/'.$item->price_delivery; ?></strong> VND</td>
	    <td align="center"><?php echo $item->countryname; ?></td>
		<td align="center">	<?php echo JHtml::_('jgrid.published', $item->published, $i, 'Products.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
		<td align="center"><?php echo $item->id; ?> </td>
      </tr>
      <?php endforeach; ?>
    </tbody>
  </table>

	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />	
    <?php echo JHtml::_('form.token'); ?> </div>
</form>
